from flask_wtf import FlaskForm
from wtforms import StringField, SelectField, TextAreaField, DateTimeField, IntegerField
from wtforms.validators import DataRequired, Length, NumberRange, Optional
from wtforms.fields import DateField

class HierarchyForm(FlaskForm):
    node_id = StringField('节点ID', validators=[DataRequired(), Length(max=50)])
    parent_id = SelectField('父节点', choices=[], coerce=str, validators=[Optional()])
    level = SelectField('层级', choices=[
        ('L1', 'L1 - 业务域'), 
        ('L2', 'L2 - 业务能力'), 
        ('L3', 'L3 - 核心流程'), 
        ('L4', 'L4 - 子流程'), 
        ('L5', 'L5 - 业务活动')
    ], validators=[DataRequired()])
    code = StringField('编码', validators=[DataRequired(), Length(max=50)])
    name = StringField('名称', validators=[DataRequired(), Length(max=100)])
    version = StringField('版本号', validators=[Length(max=20)])

class ClassificationForm(FlaskForm):
    hierarchy_node_id = SelectField('业务层级', choices=[], validators=[DataRequired()])
    type_id = SelectField('需求类型', choices=[], validators=[DataRequired()])
    request_time = DateTimeField('提出时间', format='%Y-%m-%dT%H:%M', validators=[Optional()])
    expected_solve_time = DateTimeField('期望解决时间', format='%Y-%m-%dT%H:%M', validators=[Optional()])
    business_value = SelectField('业务价值', choices=[
        (1, '1 - 很低'), (2, '2 - 低'), (3, '3 - 中'), (4, '4 - 高'), (5, '5 - 很高')
    ], coerce=int, validators=[DataRequired()], default=3)
    complexity = SelectField('实施复杂度', choices=[
        (1, '1 - 很简单'), (2, '2 - 简单'), (3, '3 - 中等'), (4, '4 - 复杂'), (5, '5 - 很复杂')
    ], coerce=int, validators=[DataRequired()], default=3)
    urgency = SelectField('紧急程度', choices=[
        (1, '1 - 不紧急'), (2, '2 - 不太紧急'), (3, '3 - 中等'), (4, '4 - 紧急'), (5, '5 - 很紧急')
    ], coerce=int, validators=[DataRequired()], default=3)
    value_metric = StringField('价值量化指标', validators=[DataRequired()])
    impact_dimensions = StringField('服务四维度影响', validators=[Optional()])
    description = TextAreaField('需求描述', validators=[DataRequired()])
    solution_owner = StringField('解决方案负责人', validators=[Optional()])